import joblib
from sklearn.metrics import classification_report
import clean_data
import train_model
class model_predict():
    def __init__(self,model):
        self.model = model
    def load(self,file):
        a = clean_data.clean_data(file)
        data = a.data
        contents, labels = data['x'], data['y']
        contents = a.tradition_tcc(contents)
        contents = a.speech_filter(contents)
        df = a.remove_null(contents, labels)
        a.save_csv(df, './data/04测试集.csv')

    def predict(self):
        a = train_model.train_model('./data/04测试集.csv')
        data = a.data
        vectorizer = joblib.load('vectorizer.pkl')
        x = vectorizer.transform(data['contents'])
        y = data['labels']
        model = joblib.load(self.model)
        y_pre = model.predict(x)
        print(classification_report(y, y_pre))
# load()
a = model_predict('aaa.pth')
a.predict()